#pragma once
#include "MeshData.h"
#include <memory>
#include <string>

using namespace std;

namespace DYGraphics
{
	class _declspec(dllexport) Mesh
	{
	public:
		Mesh();
		Mesh(MeshData* pMeshData);
		void Apply();
		void Draw();
		~Mesh();
	public:
		void SetName(const std::string& name)
		{
			mData->name = name;
		}

		std::string GetName() const
		{
			return mData->name;
		}

		int GetVertexCount() const 
		{ 
			return mData->vertexCnt; 
		}

		int GetIndexCount() const
		{
			return mData->indiceCnt;
		}

		void SetMeshData(MeshData* pMeshData)
		{
			if (mData != nullptr)
			{
				mData->Destroy();
				delete mData;
				mData = nullptr;
			}

			mData = pMeshData;
		}

		void SetVertices(int vertexCnt, Vertex* vertices)
		{
			mData->vertexCnt = vertexCnt;
			mData->vertices = vertices;
		}

		void SetIndices(int indiceCnt, unsigned int* indices)
		{
			mData->indiceCnt = indiceCnt;
			mData->indices = indices;
		}
	private:
		MeshData* mData;
		// 顶点数组对象
		unsigned int vao, vbo, ebo;
	};

	typedef shared_ptr<Mesh> MeshPtr;
}